@echo off
setlocal enabledelayedexpansion

cd vue-electron-front
call  npm install
call npm run build
xcopy "./dist" "../vue-electron-app/src/dist" /E /I /Y
cd ../vue-electron-app
call npm install
for /f %%v in ('git describe --tags --abbrev^=0') do set git_version=%%v
echo Git version: %git_version%

set "package_json=package.json"
for /f "delims=" %%l in (%package_json%) do (
    set "line=%%l"
    echo !line! | findstr /C:"\"version\":" >nul
    if !errorlevel! equ 0 (
        @REM echo Updating version in %package_json%
        echo "version": "%git_version%", >> updated_package.json
    ) else (
        echo !line! >> updated_package.json
    )
)
move /y updated_package.json %package_json%
call npm run dist
